Component Diagram
It is a structural diagram that shows how components are connected and how they interact to form larger software systems. It visualizes the organization and dependencies among a set of components.
What is a Component?
A component represents a modular part of a system that encapsulates its contents and defines its behavior in terms of provided and required interfaces. In simpler terms, components are self-contained units that can be replaced independently.
Components
- Component:
- A self-contained module with well-defined functionality, like a class, module, or microservice.
- Represented as a rectangle with the stereotype «component».
+------------------------+
| «component» |
| Book Management |
+------------------------+
- Interface:
- Defines how components communicate—what services they provide and require.
- Types:
- Provided Interface (lollipop-○): what a component offers.
- Required Interface (socket-◐): what a component needs.
- Relationships:
- Dependency (dashed arrow): One component depends on another.
- Association (solid line): A structural link.
- Assembly Connector: Connects required to provided interfaces.
- Ports:
- Interaction point on the boundary of a component.
- Represented as small square on the component’s edge.
- Artifacts:
- A physical file or piece of code/data
- Real-world outputs like executable files or data.
- Shown as rectangles with «artifact».
- Nodes:
- Physical/virtual environments where components run.
- Shown as 3D boxes.
Example:
+--------------------------+
| «component» |
| UserInterface |
| |
| ◐ searchBooks() |
| ◐ borrowBook() |
| ◐ returnBook() |
+----------◼--------------+
|
▼
+--------------------------+
| «component» |
| BookService |
| ○ searchBooks() |
| ◐ getBookDetails() |
| ◐ updateAvailability() |
+----------◼--------------+
|
▼
+--------------------------+
| «component» |
| LoanService |
| ○ borrowBook() |
| ○ returnBook() |
| ◐ calculateFines() |
+----------◼--------------+
|
▼
+--------------------------+
| «component» |
| NotificationService |
| ○ sendDueAlert() |
| ○ sendOverdueNotice() |
+--------------------------+
(All components read/write to:)
+--------------------------+
| «artifact» |
| LibraryDB.sql |
+--------------------------+